# 7.列表推导式
# 快速的得到0~10之间偶数集的列表，0,2,4,6,8
# a = [0, 2, 4, 6, 8]
# b = [i for i in a]  # 列表推导式
# print(b)
# # 等同于下列代码
# c = []
# for i in a:
#     c.append(i)

# d = [i for i in range(10) if i % 2 == 0]
# print(d)
# # 等同于下列代码
# d = []
# for i in range(10):
#     if i % 2 == 0:
#         d.append(i)

# e = []
# for i in range(5):
#     e.append(2 * i)
# print(e)
# # 推导式写法
# e = [2 * x for x in range(5)]
# print(e)

# f = []
# # 2是步长，也就是间隔
# for i in range(0, 10, 2):
#     f.append(i)
# print(f)
# f = [x for x in range(0, 10, 2)]
# print(f)

# 循环嵌套推导式写法
g = []
for i in range(5):
    for j in range(5):
        g.append((i, j))
print(g)
g = [(i, j) for i in range(5) for j in range(5)]
print(g)